"""
Boss直聘
https://v.qq.com/biu/ranks/?t=hotsearch
"""

import requests
from pyquery import PyQuery as pq
import json

headers = {
    # "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
    # "Referer": "https://music.163.com/",
    # "Cookie": "NMTID=00OIkU_p5Cim90Bf0l7hcA7g1tjpuwAAAGPheJ9CQ; JSESSIONID-WYYY=AJ1rjcO8qQgGHUutE%2FBF02EgalAE7EFVYRFqK56bbdVytHiV%2FmKEhfbr8PB8NXS03ij%2BYe7AZy2IwnrSlpBekfV7r735tnvOtSOWzY%5C%5C6spvx5GtJKHMZpb6mn5Jffv4KDS4xw5gC9BEnzA8W%5Cyn0DmkDHHiGE2U0uXdm1c6uxlp%2Fx4u%3A1715939962279; _iuqxldmzr_=32; _ntes_nnid=2b1622cbaa028bbf235eb63f71282ce2,1715938162293; _ntes_nuid=2b1622cbaa028bbf235eb63f71282ce2; WEVNSM=1.0.0; WNMCID=nyewim.1715938163758.01.0; WM_NI=Y8WxuPPjVc1%2FFZkm%2F1YTELWG5X%2BhW6gGXL9Af%2BzNgiDEnyqWUS5Y7YHvQj7xs4vP5Hra%2Fs8qPDXG%2FEaaFMF0GTu66OKZyTkydCJo%2BTVNCj7v%2BuiQYHVHvn2qm9NlkUH7VkU%3D; WM_NIKE=9ca17ae2e6ffcda170e2e6ee8ffb6988aaacd9ee4ba3b48eb2c84e938a8e86d83dfb8ba796d16286b498b4bb2af0fea7c3b92a9be89999f85c94b69a84b4258686a58eae3b9b8c8badd64df788e589d63ea59998adbc4ba6f5b6afe663889ba29af45d978dfbbab6538caa9f8bb674b1ecbab1b844b2bfe194bb7b949c98a8ae4fa3bf8aaec53c858cbbd7b5458986b7b5ea73a89d8690aa6096928d8bb67ee9aba7b2dc449698ba8fb17bafe7828dea5f8ce99a8cd837e2a3; WM_TID=28X4vjA85jdAFQAUBUaV78VivU3EwSD9; sDeviceId=YD-iJMIWvtnsPNAVkUQFEKAu9Ei7RjAkh0d; ntes_utid=tid._.we3EDKq%252B3IdFF1FAFVLUq9EyrV3FgDvT._.0; __snaker__id=yutNIVRbdtnqUUrZ; gdxidpyhxdE=Lfte3oYOq2BlVaI%2FDiLysIreB4dHzOt8eur8s%2B%2F4qtMu5XgBgxsyp7UQqIYwspnxqMRHi5AcOeBkylTpifoIqXcQ%2FIr54XcJqJpuOxuHxjznCOTik4x8QeU2eANfVTIUX3gRcnoaGKMJUtWzurXT4iySXgVpJo3Ys6HhPTO%2BoJAhkJ%2Fq%3A1715939561462; NTES_YD_SESS=OGJEhi1W_l0TXrl_y128xCGLY5iaqrqsGQ90uGZ7I9GTa7s5atXR4yJ34B.bQKSU8ASAGp7sT2TG7rqWdPLRg5va0BAuZ7Q_bQIcdej_uhEccGLSfl8ChJRjZ8TV22DQsAuNe24xmPxFbufliSGikdls.THnfNQVzf0jp3WdFKr4gbVXCupZp0qhv7NraUxgbhf4SAyqoaS2404_tuD_y2cEdGxwlEuFbFzfANh1DJ76n; S_INFO=1715938690|0|0&60##|18860262882; P_INFO=18860262882|1715938690|1|music|00&99|null&null&null#hen&410100#10#0|&0||18860262882; MUSIC_U=000048F5CAB623B2065D9FFBCDF9C5C6610254F7D2318A8740F139C488E94B7D9FBAD2B03B02B16F57644447DA19F473C8EEC2D71A98476A1EA0DA5666F09C305C144D29C553B5D19371FFA08A1F336DF16D9942D7AA5DED66AEFACF7C664124A5A77B2BA8478D86F82DAD95B4CF9610607EEBB840F09D7357DAD1A9F539F489AC2DE7832FDC73E35252F5CD42761EA5AA01B7E7F78B13CA22F21D9B89601137555D5780E2522F5A44AFFFC979F89C9BF3090B67C0BAA74EB3362A134EAFE72A93A0A48932D6CAE39064EFDEE64C6005F92DE7DF4B9B67AAC5C184C6041E87E965B55E9FB2D7E3AB629A1D0357D6654605A9563F085A2D06489D494653EF7947FF2EAAB9BED73C6A14AFB1AFED633C0C8617F0920092F81E6AEC73D974A028B6265177BED84AE99CFDFFC5067BCD9F49385E29F23B48B61A903ECD6C3502D58C0C486B9A1EE98723133ABEA5013080C3E954A24C79322B9D950B69D8C5219AE7D5; __remember_me=true; __csrf=39380a5e89df77c903aab138596e9cf9; ntes_kaola_ad=1"
}
url = "https://v.qq.com/biu/ranks/?t=hotsearch"
res = requests.get(url, headers=headers)
# print(res.content.decode())
query = pq(res.content.decode())
ranks = query(".mod_row_box .mod_bd .mod_rank_wrap .mod_rank_figure")
for rank in ranks:
    rank_query = pq(rank)
    # print(rank_query)
    title = rank_query(".mod_rank_figure .mod_rank_title h3").text()
    hot_lists = rank_query(".mod_rank_list .mod_rank_search_list .hotlist li")
    for list_query in hot_lists:
        list_query = pq(list_query)
        # print(list_query)

        link = "https:" + list_query("li a").attr("href")
        name = list_query("li a .name").text()
        print(link, name)
        # break
    print(title, len(hot_lists))
    # break

